package com.example.lc.mythreedemo.custom;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

import com.example.lc.mythreedemo.EnterpriseHomeEntity;
import com.example.lc.mythreedemo.SelectNameCardTemplateFragment;
import com.example.lc.mythreedemo.SelectNameCardTemplateFragmentTwo;

import java.util.List;

/**
 * 描述
 *
 * @author: lc
 * @data: 2016/10/18 10:28
 * Created by  2016 广州聚酷软件科技有限公司 All Right Reserved
 */

public class ViewPageAdapter extends FragmentPagerAdapter {
    private List<EnterpriseHomeEntity> list;

    private Context context;

    public ViewPageAdapter(FragmentManager fm, Context context, List<EnterpriseHomeEntity> list) {
        super(fm);
        this.context = context;
        this.list = list;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1 || position == 3) {
            SelectNameCardTemplateFragmentTwo selectNameCardTemplateFragmenttwo = SelectNameCardTemplateFragmentTwo.newInstance(list);
            return selectNameCardTemplateFragmenttwo;
        } else {
            SelectNameCardTemplateFragment selectNameCardTemplateFragment = SelectNameCardTemplateFragment.newInstance(list);
            return selectNameCardTemplateFragment;
        }
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getTitle();
    }
}
